package com.bdqn.crm.config;

import org.springframework.cache.annotation.CachingConfigurerSupport;

import javax.crypto.KeyGenerator;
import java.lang.reflect.Method;

public class RedisConfig extends CachingConfigurerSupport {

    public KeyGenerator keyGenerator(){
        return new KeyGenerator() {
            @Override
            public Object generate(Object target, Method method, Object... params) {
                // 格式化缓存key字符串
                StringBuilder sb = new StringBuilder();
                sb.append(target.getClass().getName());
                sb.append(method.getName());
                for (Object obj : params) {
                    sb.append(obj.toString());
                }
                return sb.toString();
            }
        };
    }


}
